/**
 * 读取文件内容的函数
 * 参数: path 文件路径
 * 返回: promise对象
 * @param path
 */
function mineReadFile(path){
    return new Promise(((resolve, reject) => {
        //读取文件
        require('fs').readFile(path,(err,data)=>{
            if (err) reject(err)
            else resolve(data)
        })
    }))
}

mineReadFile('/Users/wangzhiyuan/Documents/myfile/js/thinking-in-java-script/promise/hello.txt').then(value => {
    console.log(value.toString())
},reason => {
    console.warn(reason.toString())
})
